﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WeakScript
{
    public partial class ContextListBox : ListBox
    {
        public ContextListBox()
        {
            InitializeComponent();
            this.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index < 0) return;
            //ForeColor = Color.BlueViolet;
            //base.OnDrawItem(e);
            e.DrawBackground();
            e.Graphics.DrawRectangle(Pens.DarkBlue, e.Bounds);
            e.Graphics.DrawString(Items[e.Index].ToString(), Font, Brushes.DarkCyan, e.Bounds);
            e.DrawFocusRectangle();
        }

        public void AddItem(string str)
        {
            Items.Add(str);
        }

        public void AddItems(string[] str)
        {
            foreach (var item in str)
            {
                AddItem(item);
            }
        }

        public void CleanItems(){
            Items.Clear();
        }
    }
}
